package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.model.menu.MenuPo;
import com.example.demo.model.menu.MenuSub;
import com.example.demo.model.request.VpsPageRequest;
import com.example.demo.model.response.AddressResponse;
import com.example.demo.service.order.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/menu/")
public class MenuController {


    @GetMapping(value = "list")
    public ResultObject<MenuPo> queryMenu() {

        ResultObject<MenuPo> resultObject = new ResultObject<>();
        MenuPo menuPo = new MenuPo();
        List<MenuSub> menuSubs = new ArrayList<>();
        //下单
        MenuSub applyMenu = new MenuSub();
        applyMenu.setCode("applyMenu");
        applyMenu.setIndex(1);
        applyMenu.setInternationalText("测评下单");
        applyMenu.setName("applyList");
        applyMenu.setValue("/applyList");
        menuSubs.add(applyMenu);

        //订单
        MenuSub orderMenu = new MenuSub();
        orderMenu.setCode("orderMenu");
        orderMenu.setIndex(2);
        orderMenu.setInternationalText("订单");
        orderMenu.setName("orderList");
        orderMenu.setValue("/orderList");
        menuSubs.add(orderMenu);
        //账号
        MenuSub accountMenu = new MenuSub();
        accountMenu.setCode("accountMenu");
        accountMenu.setIndex(3);
        accountMenu.setInternationalText("买家账号");
        accountMenu.setName("accountList");
        accountMenu.setValue("/accountList");
        menuSubs.add(accountMenu);
        //邮箱
        MenuSub emailMenu = new MenuSub();
        emailMenu.setCode("emailMenu");
        emailMenu.setIndex(4);
        emailMenu.setInternationalText("邮箱");
        emailMenu.setName("emailList");
        emailMenu.setValue("/emailList");
        menuSubs.add(emailMenu);
        //地址
        MenuSub addressMenu = new MenuSub();
        addressMenu.setCode("addressMenu");
        addressMenu.setIndex(5);
        addressMenu.setInternationalText("地址");
        addressMenu.setName("addressList");
        addressMenu.setValue("/addressList");
        menuSubs.add(addressMenu);
        //vps
        MenuSub vpsMenu = new MenuSub();
        vpsMenu.setCode("vpsMenu");
        vpsMenu.setIndex(6);
        vpsMenu.setInternationalText("vps");
        vpsMenu.setName("vpsList");
        vpsMenu.setValue("/vpsList");
        menuSubs.add(vpsMenu);
        //虚拟机
        MenuSub virtualMenu = new MenuSub();
        virtualMenu.setCode("virtualMenu");
        virtualMenu.setIndex(7);
        virtualMenu.setInternationalText("虚拟机");
        virtualMenu.setName("virtualList");
        virtualMenu.setValue("/virtualList");
        menuSubs.add(virtualMenu);
        //虚拟卡
        MenuSub cardMenu = new MenuSub();
        cardMenu.setCode("cardMenu");
        cardMenu.setIndex(8);
        cardMenu.setInternationalText("虚拟卡");
        cardMenu.setName("cardList");
        cardMenu.setValue("/cardList");
        menuSubs.add(cardMenu);

        menuPo.setGrantedSubmenu(menuSubs);
        resultObject.setData(menuPo);
        return resultObject;

    }


    /**
     * 查询二级菜单
     * @return
     */
    @GetMapping(value = "submenu/list/{menuId}")
    public ResultObject queryMenuSub(@PathVariable("menuId") String menuId) {
        return new ResultObject();

    }
}
